/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package swing.dialog;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author Administrator
 */
public class AboutDialog extends JDialog implements ActionListener
{
  public AboutDialog(JFrame parent, String title, String message)
  {
    super(parent, title, true);
    if (parent != null)
    {
      Dimension parentSize = parent.getSize();
      Point p = parent.getLocation();
      setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
    }
    JPanel messagePane = new JPanel();
    messagePane.add(new JLabel(message));
    getContentPane().add(messagePane);
    JPanel buttonPanel = new JPanel();
    JButton button = new JButton("OK");
    buttonPanel.add(button);
    button.addActionListener(this);
    getContentPane().add(button, BorderLayout.NORTH);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    setSize(300, 400);
    setVisible(true);
    
  }
  public void actionPerformed(ActionEvent e)
  {
    setVisible(false);
    dispose();
  }
  public static void main(String[] args)
  {
    AboutDialog dialog = new AboutDialog(new JFrame(), "title", "message");
  }
}
